<?php
class ProfileController extends Zend_Controller_Action
{
    protected $identity;
    
	function init() 
	{
	    // Get the users identity
	    $this->identity = Zend_Auth::getInstance()->getIdentity();
        if (!$this->identity) {
           throw new Exception('User not logged in, but viewing profile pages');
        }
	}
	
	function indexAction()
	{
	    // Attempt to get the user from params
	    $user = Users::getById($this->_request->getParam('user'));
	    if (!$user) {
	        $user = Users::getById($this->identity->id);
	    }
	    
	    $characters = $user->findDependentRowset('Characters','User');
	         
	    $this->view->user = $user;
	    $this->view->characters = $characters;
	    $this->view->ownProfile = ($user->id == $this->identity->id);
	}
	
	function editAction()
	{
	    $user = Users::getById($this->identity->id);
	    $this->view->user = $user;
	}
	
	function showAction()
	{
	    
	}
}

?>